<!DOCTYPE html>
<html>
<head>
	<title>JBlog登录</title>
	<link rel="stylesheet" href="${rc.contextPath}/resources/css/login.css">
</head>
<body>
	<div class="login-dlg">
		<form action="/login" id="login-form" method="POST" autocomplete="off" onsubmit="return checkSubmit();">
			<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>
			<input type="text" name="jblog_username" placeholder="username">
			<input type="password" name="jblog_password" placeholder="password">
			<div id="popup-captcha"></div>
			<button id="btn-submit">Login</button>
		</form>
		<#if errorMsg ??>
		<div class="exception-msg">${errorMsg}</div>
		</#if>
	</div>
	<script src="${rc.contextPath}/resources/js/jquery.min.js"></script>
	<script src="https://static.geetest.com/static/tools/gt.js"></script>
	<script type="text/javascript">
		var captchaObj;

		$(function(){
			$.get("${rc.contextPath}/getGeetestStep1Data", function(result){
				if(result.data.success == 1){
					initGeetest({
		                gt: result.data.gt,
		                challenge: result.data.challenge,
		                product: "popup",
		            }, handlerFloat);
				}
			},"json");

			var handlerFloat = function (me) {
				// 将验证码加到id为popup-captcha的元素里
				captchaObj = me;
				captchaObj.bindOn("#btn-submit");
				captchaObj.appendTo("#popup-captcha");
			};
		});

		function checkSubmit(){
			if(captchaObj.getValidate()){
				return true;
			}else{
				captchaObj.show();
				return false;
			}
		}
	</script>
</body>
</html>